import Vue from 'vue'
import VueRouter from 'vue-router'    //导入路由插件
import Home from '../views/Home.vue'  //导入组件页面

Vue.use(VueRouter)  //在Vue中注册路由插件

//路由数组，存储着当前项目的路由信息
const routes = [
  {
    path: '/',        //路由路径
    name: 'Home',     //路由名称
    component: Home   //当前路由路径所对应的组件
  },
  {
    path: '/about',
    name: 'About',
    component: () => import('../views/About.vue')   //懒加载方式，按需加载：需要则加载；不需要则不加载
  },
  {
    path:'/example',
    name:'Example',
    component:() => import('../views/Example.vue')
  },
  {
    path:'/login',
    name:'Login',
    component:()=>import('@/views/Login.vue')
  },
  {
    path:'/userInfo',
    name:'UserInfo',
    component:()=>import('@/views/UserInfo.vue')
  },
  {
    path:'/score',
    name:'Score',
    component:()=>import('@/views/Score.vue')
  }
]

//将路由数组作为参数，传递给路由构建器，创建一个路由实例对象
const router = new VueRouter({
  routes
})

export default router
